<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义指令directive-局部焦点</title>
    <script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
</head>
<body>
<div id="case11-demo2">
    <p>页面载入时,input 元素自动获取焦点</p>
    <input v-focus>
</div>
<script type="text/javascript">
    var case11Demo2=new Vue({
        el:"#case11-demo2",
        directives:{
            //注册一个局部的自定义指令 v-focus
            focus:{
                //指令定义
                inserted:function (el) {
                    //聚焦元素
                    el.focus()
                }
            }
        }
    })
</script>
</body>
</html>